class ParkingAdministrators{
  constructor(){
    this.firstParkingLot=this.createParkingLot()
    this.secondParkingLot=this.createParkingLot()
  }
  createParkingLot(){
    let parkingLot=[]
    for (let index = 1; index <=10; index++) {
      parkingLot.push({
        id:index,
        car:null
      })
      
    }
    return parkingLot
  }
  parking(){
    let parkingId=0
    let firstUnparking=this.firstParkingLot.filter(e=>e.car===null)
    let secondUnparking=this.secondParkingLot.filter(e=>e.car===null)
    if(firstUnparking.length>=secondUnparking.length){
      parkingId=firstUnparking[0].id
      this.firstParkingLot.forEach(item=>item.id===parkingId?item.car='已停车':null)
      return {
        parkingLot:'firstParkingLot',
        id:parkingId
      }
    }
     this.secondParkingLot.forEach(item=>item.id===parkingId?item.car='已停车':null)
      return {
        parkingLot:'secondParkingLot',
        id:parkingId
      }
  }
}
module.exports = ParkingAdministrators;